package com.vv.test.auto;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class BaiDuIndex {
	
	 //百度首页的页面工厂

    @FindBy(xpath = ".//*[@id='kw']")
    private WebElement inputBox;
    //输入框

    @FindBy(xpath = ".//*[@id='su']")
    private WebElement searchButton;
    //搜索按钮
    
    

    private String baiduUrl = "https://www.baidu.com/";
    //百度地址

    private WebDriver driver;
    public BaiDuIndex(){
        //构造函数，生成浏览器对象，初始化PageFactory对象
    	System.getProperty("webdriver.gecko.driver", "d:/Driver/geckodriver.exe");
        driver = new FirefoxDriver();
        PageFactory.initElements(driver, this);
    }
    

    public void open(){
        //打开百度
        driver.get(baiduUrl);
        driver.manage().window().maximize();
    }

    public void quit(){
        //结束driver
        driver.quit();
    }

    public void searchChina(){
        //封装搜索“中国”的步骤
        inputBox.sendKeys("中国");
        //输入“中国”
        searchButton.click();
        //点击搜索按钮
    }
}



